home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Web Server / PHP.EXE / pear / PHPDoc / renderer / html / PhpdocHTMLWarningRenderer.php < prev   
Encoding:
PHP Script  |  2001-02-18  |  2.8 KB  |  90 lines

  1. <?php
  2. /**
  3. * Renders files with warnings.
  4. *
  5. * @version  $Id: PhpdocHTMLWarningRenderer.php,v 1.5 2001/02/18 16:29:21 uw Exp $
  6. */
  7. class PhpdocHTMLWarningRenderer extends PhpdocHTMLRenderer {
  8.  
  9.     /**
  10.     * Sets the xml and template root directory.
  11.     * 
  12.     * @param    string  XML file path
  13.     * @param    string  Template file path
  14.     * @param    string  Name of the application
  15.     * @param    string  Filename    extension
  16.     * @see      setPath(), setTemplateRoot()
  17.     */
  18.     function PhpdocHTMLWarningRenderer($path, $templateRoot, $application, $extension = ".html") {
  19.  
  20.         $this->setPath($path);
  21.         $this->setTemplateRoot($templateRoot);
  22.         $this->application = $application;
  23.         $this->file_extension = $extension;
  24.  
  25.         $this->accessor = new PhpdocWarningAccessor;
  26.         $this->fileHandler = new PhpdocFileHandler;
  27.  
  28.     } // end constructor
  29.  
  30.     /**
  31.     * Saves the generated report.
  32.     * 
  33.     * @see      addWarnings()
  34.     * @access   public
  35.     */
  36.     function finishWarnings() {
  37.  
  38.         if (!is_object($this->tpl)) 
  39.             return;
  40.  
  41.         $this->tpl->setVariable("APPNAME", $this->application);
  42.         $this->fileHandler->createFile($this->path."phpdoc_warnings" . $this->file_extension, $this->tpl->get() );
  43.  
  44.         $this->tpl = "";
  45.         
  46.     }    // end func finishWarnings
  47.  
  48.     /**
  49.     * Adds file with warnings to the warning list.
  50.     * 
  51.     * @param    string  XML file
  52.     * @see      finishWarnings()
  53.     * @access   public
  54.     */
  55.     function addWarnings($xmlfile) {
  56.  
  57.         $data = $this->accessor->getWarnings($this->path . $xmlfile);
  58.         if (!is_object($this->tpl)) {
  59.             $this->tpl = new IntegratedTemplate($this->templateRoot);
  60.             $this->tpl->loadTemplateFile("warnings.html");
  61.         }
  62.  
  63.         reset($data);
  64.         while (list($file, $warnings) = each($data)) {
  65.  
  66.             $this->tpl->setCurrentBlock("warning_loop");            
  67.             
  68.             reset($warnings);
  69.             while (list($k, $warning) = each($warnings)) {
  70.  
  71.                 $this->tpl->setVariable("WARNINGTYPE", $warning["type"]);
  72.                 $this->tpl->setVariable("WARNING", $this->encode($warning["value"]));
  73.                 $this->tpl->setVariable("ELEMENT", htmlentities($warning["name"]));
  74.                 $this->tpl->setVariable("ELEMENTTYPE", $warning["elementtype"]);
  75.                 $this->tpl->parseCurrentBlock();
  76.  
  77.             }
  78.  
  79.             $this->tpl->setCurrentBlock("warning");
  80.             $this->tpl->setVariable("FILE", $file);
  81.             $this->tpl->setVariable("NUMWARNINGS", count($warnings));
  82.             $this->tpl->parseCurrentBlock();
  83.  
  84.         }
  85.  
  86.         return true;
  87.     } // end func addWarnings
  88.  
  89. } // end class PhpdocHTMLIndexRenderer
  90. ?>